package com.hamster.crm.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hamster.crm.pojo.Materiel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * 物料mapper
 * @author Tarry
 * @create 2019/12/24 10:09
 */
@Repository
@Mapper
public interface MaterielMapper extends BaseMapper<Materiel> {
    /**
     * 标记删除
     */
    @Update("update materiel set del = 1 where id = #{id}")
    void deleteTag(String id);

    @Insert("insert into materiel(id,title,materiel_config_id,count,remark,input_user,input_time,del) values (#{materiel.id},#{materiel.title},#{materiel.materielConfigId},#{materiel.count},#{materiel.remark},#{materiel.inputUser},#{materiel.inputTime},#{materiel.del})")
    void insertMateriel(@Param("materiel") Materiel materiel);

    /**
     * 根据类型id，查询类型名称
     * @param materielConfigId
     * @return
     */
    @Select("select title from materiel_config where id = #{id}")
    String selectTypeName(@Param("id") String materielConfigId);
}
